/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.cloudminga.gui;
import java.io.*;
import java.io.FileWriter;
import java.net.URL;
import javax.xml.parsers.ParserConfigurationException;

public  class Logger {
   
     private static  boolean logInconsole=true;
     public static  boolean logInfile=false;

     // get application directory
     static  URL mySource = Logger.class.getProtectionDomain().getCodeSource().getLocation();
     static File sourceFile = new File(mySource.getPath());

     // attach text file to application directory(.class file)
     static String logfile = sourceFile+"\\"+"log.txt";

    

     public void Logger() // constructer
     {
    
     }

      // LogInConsole setter
     public static void LogInConsole(boolean value)
    {
         logInconsole = value;
    }

     // LogInFile setter
    public static void LogInFile(boolean value) 
    {
         logInfile = value;
    }

    // LogText method
    public static void LogText(String text)
    {
     try                     // try block
        {
             if(logInfile == true)
             {
                    
                      BufferedWriter out = new BufferedWriter(new FileWriter(logfile, true));
                      out.write(text);
                      out.close();      
                      return;
              } //end if
            if(logInconsole ==true)
             {
                      // print text value in console
                      System.out.println(text);
             } //end if
                   
        }catch(Exception e) 
          {
                       e.printStackTrace();
          }// end try-catch block

    }//end of LogText method


}//end of Logger class
